#!/bin/bash

tempBaseDir="/Library/Application Support/com.onefatgiraffe/mailtrackerblocker"
running="$tempBaseDir/running"

rm -rf "$tempBaseDir"
mkdir -p "$tempBaseDir"

if [ $(osascript -e 'return application id "com.apple.Mail" is running') == "true" ]; then
    touch "$running"
fi

echo $running

#####
# We politely asked the user to quit Mail in the installer intro.  Now
# we'll request the same a bit more strongly.
####
osascript -e "quit app \"Mail\""

# Delete any old copies of the bundle
rm -rf /Library/Mail/Bundles/MailTrackerBlocker.mailbundle

exit 0
